package es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions;

import es.udc.emarketapp.emarket.model.purchase.dao.SQLPurchaseDAO;
import es.udc.emarketapp.emarket.model.purchase.dao.SQLPurchaseDAOFactory;
import es.udc.fbellas.j2ee.util.exceptions.InstanceNotFoundException;
import java.sql.Connection;

import es.udc.fbellas.j2ee.util.exceptions.InternalErrorException;
import es.udc.fbellas.j2ee.util.sql.NonTransactionalPlainAction;

public class FindLastPurchaseByClientAction implements NonTransactionalPlainAction {

	private String idClient;

	public FindLastPurchaseByClientAction(String idClient) {
		this.idClient = idClient;
	}

	public Object execute(Connection connection) 
                throws InternalErrorException, InstanceNotFoundException {

		SQLPurchaseDAO purchaseDAO = SQLPurchaseDAOFactory.getDAO();

		return purchaseDAO.findLastByClient(connection, idClient);

	}
}
